//
//  WCNAllowBeNursingPeopleVC.m
//  WCN
//
//  Created by wsj2015 on 16/4/8.
//  Copyright © 2016年 ShanghaiCize Trade And Business Co., Ltd. All rights reserved.
//

#import "WCNAllowBeNursingPeopleVC.h"
#import "MyAttributedStringBuilder.h"

@interface WCNAllowBeNursingPeopleVC ()
@property (weak, nonatomic) IBOutlet UILabel *inforLabel;
@property (weak, nonatomic) IBOutlet UIButton *rejectBtn;
@property (weak, nonatomic) IBOutlet UIButton *agreenBtn;
@property (weak, nonatomic) IBOutlet UILabel *handleInforLabel;

@end

@implementation WCNAllowBeNursingPeopleVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self setupUI];
}
- (void)setupUI{
   
    
    self.title = @"消息详情";
    self.rejectBtn.layer.cornerRadius =4;
    self.rejectBtn.layer.masksToBounds = YES;
    self.agreenBtn.layer.cornerRadius =4;
    self.agreenBtn.layer.masksToBounds = YES;
//    
//    MyAttributedStringBuilder *builder =[[MyAttributedStringBuilder alloc] initWithString:[NSString stringWithFormat:@"张医生邀请您共同护理患者%@",self.name]];

//    [builder includeString:self.name all:YES].textColor =[UIColor orangeColor];
//    self.inforLabel.attributedText = builder.commit;
    self.inforLabel.text = self.name;
    
    if (self.handleInfor) {
        [self disableAllBtns];
        if (self.handleInfor ==201) {
            self.handleInforLabel.text = @"您已经同意过";
        }else if(self.handleInfor ==202){
            self.handleInforLabel.text = @"您已经拒绝过";
        }
        
    }else{
      self.handleInforLabel.text = @"";
    }
 
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (IBAction)rejectAciotn:(id)sender {
    [self postToService:0];
    
}
- (IBAction)agreenAction:(id)sender {
    [self postToService:1];
}
- (void)postToService:(NSInteger)isAgree{
  
//    "messageId": 1,
//    "memberId": 1,
//    "agreeStatus": 1
    defineWeakSelf;
    CoreSVPLoading(@"正在同步...", NO);
    NSMutableDictionary *params =[NSMutableDictionary dictionary];
    params[@"agreeStatus"] =@(isAgree);
    params[@"messageId"] =@(self.messageId);
    params[@"memberId"] =@(self.nursingPeopleId);
    [[WCNetworkAccessManager sharedMg] POST:kAgreeOrRefuseToBePatientNursingMember parameters:params success:^(NSDictionary *responseObject) {
        
        
       
        if ([responseObject[@"success"] integerValue] ==0) {
            CoreSVPError(responseObject[@"data"]);
            return ;
        }
        CoreSVPSuccess(responseObject[@"data"]);
        [weakSelf.navigationController popViewControllerAnimated:YES];
    } failure:nil netError:nil always:^{
        [CoreSVP dismiss];
        [weakSelf disableAllBtns];
       
    }];
   

}
- (void)disableAllBtns{
    self.rejectBtn.enabled = NO;
    self.agreenBtn.enabled = NO;
    [self.rejectBtn setBackgroundColor:[UIColor grayColor]];
    [self.agreenBtn setBackgroundColor:[UIColor grayColor]];

}

@end
